import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName LC590
 * @Author ykx
 * @Date 2024/3/25 9:52
 * @Version 1.0
 */
public class LC590 {
    public static void main(String[] args) {

    }

    public List<Integer> postorder(Node root) {
        List<Integer> result = new ArrayList<>();
        postorder(root, result);
        return result;
    }

    public void postorder(Node root, List<Integer> result) {
        if (root != null) {
            for (Node child : root.children) {
                postorder(child, result);
            }
            result.add(root.val);
        }
    }

}
